import { typeStatus } from "@/interface/public";
import { CSSProperties } from "vue";

export interface CustomForm<T> {
  editable?: boolean;
  operationFlag?: typeStatus["operationFlag"];
  form?: T;
  save?: () => void;
  options: FromOptionsProp[];
  checkedProp?: string;
  transitionArr?: transitionProps[];
}
export interface transitionProps {
  newField: string;
  oldField: string;
}

export interface FromOptionsProp {
  hide: boolean;
  label: string;
  prop?: string;
  dateVisible?: boolean; // 时间弹框是否打开
  type?: "skip" | "input" | "title" | "select" | "slot" | "select_custom" | "date" | "date_custom" | "data_picker";
  skipParams?: skipParamsProp;
  slot?: string;
  rules?: rulesProp[];
  attrs?: attrsProp;
  correctionParams?: correctionParamsProp;
  defaultValue?: any;
  children?: childrenProps[];
  clearMethod?: () => void;
  changeMethod?: (form?: any) => void;
  inputMethod?: (form: any) => void;
  blurFunction?: (form?: any) => void;
}

interface skipParamsProp {
  url: string;
  disableDefaultSkip?: boolean;
  customSkipMethod?: (form?: any, prop?: string) => void;
  params?: {};
}

interface rulesProp {
  required: boolean;
  errorMessage: string;
}

interface attrsProp {
  placeholder?: string;
  type?: "daterange" | "datetimerange" | "datetime" | "digit" | "number" | "text";
  style?: CSSProperties;
  disabled?: boolean;
  clearable?: boolean;
  clear?: boolean;
  readonly?: boolean;
}

interface correctionParamsProp {
  digit: 0 | 1 | 2;
  correctionMethod?: (form: any) => void;
}

export interface childrenProps {
  text: string;
  value: string | number;
  disable?: boolean;
  tag?: typeStatus["colorStatus"];
  children?: childrenProps[];
}
